<!doctype html>
<html lang="en-us">
  <head>
    <meta charset="utf-8">
    <meta name="Miskeenity Canvas"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
    <title>Miskeenity Canvas</title>
    <link rel="icon" type="image/png"
      href="https://raw.githubusercontent.com/sava41/miskeenity-canvas/main/resources/textures/miskeen_32.png">
    <style>
        body { margin: 0; background-color: black }
        .game {
            position: absolute;
            top: 0px;
            left: 0px;
            margin: 0px;
            border: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            display: block;
            image-rendering: optimizeSpeed;
            image-rendering: -moz-crisp-edges;
            image-rendering: -o-crisp-edges;
            image-rendering: -webkit-optimize-contrast;
            image-rendering: optimize-contrast;
            image-rendering: crisp-edges;
            image-rendering: pixelated;
            -ms-interpolation-mode: nearest-neighbor;
        }
        #splash-screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: black;
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: Arial, sans-serif;
            font-size: 24px;
            text-align: center;
        }
    </style>
  </head>
  <body>
    <canvas class="game" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
    <div id="splash-screen" style="display: none;">
      <p>WebGPU is not available in your browser.<br>Please use a WebGPU compatible browser to run this application.</p>
    </div>
    <script type='text/javascript'>
      var Module = {
        preRun: [],
        postRun: [],
        print: (function() {
            return function(text) {
                text = Array.prototype.slice.call(arguments).join(' ');
                console.log(text);
            };
        })(),
        printErr: function(text) {
            text = Array.prototype.slice.call(arguments).join(' ');
            console.error(text);
        },
        canvas: (function() {
            var canvas = document.getElementById('canvas');
            return canvas;
        })(),
        setStatus: function(text) {
            console.log("status: " + text);
        },
        monitorRunDependencies: function(left) {
            console.log("monitor run deps: " + left);
        }
      };
      window.onerror = function() {
        console.log("onerror: " + event.message);
      };

      // Check for WebGPU support
      if (navigator.gpu) {
        (async () => {
          try {
            const adapter = await navigator.gpu.requestAdapter();
            const device = await adapter.requestDevice();
          } catch(error) {
            document.getElementById('splash-screen').style.display = 'flex';
            document.getElementById('canvas').style.display = 'none';
            return;
          }
        })();
      } else {
        document.getElementById('splash-screen').style.display = 'flex';
        document.getElementById('canvas').style.display = 'none';
      }
    </script>
    {{{ SCRIPT }}}
  </body>
</html>